﻿
@{
    Layout = null;
}
<!DOCTYPE html>
<h2>医生编辑信息</h2>
<html>

<head>

    <link href="~/BootstrapS/css/bootstrap.min14ed.css" rel="stylesheet" />
    <link href="~/BootstrapS/css/font-awesome.min93e3.css" rel="stylesheet" />
    <link href="~/BootstrapS/css/animate.min.css" rel="stylesheet" />
    <link href="~/BootstrapS/css/style.min862f.css" rel="stylesheet" />
    <script src="~/vue/vue.min.js"></script>
    <script src="~/vue/qs.min.js"></script>
    <script src="~/vue/axios.min.js"></script>
</head>

<body>
    <div id="updiv">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size:30px">&times;</button>
            
        </div>
        <div>
            <div style="width:45%;float:left;margin-left:20px;margin-top:15px">
                医生
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0"  v-model="Name" style="width:240px">
                <br /><br />
                医龄
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" v-model="Age" style="width:240px">
                <br /><br />
                邮箱地址
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0"  v-model="Email" style="width:240px">
                <br /><br />
                医生职称<br />
                <select class="btn btn-outline btn-success" style="width:200px" v-model="Profid">
                    <option style="background-color:white;color:black" v-bind:value="0">请选择职称</option>
                    <option style="background-color:white;color:black" v-for="item in pfl" v-bind:value="item.professional_Id">{{item.professional_Name}}</option>
                </select>
                <br /><br /><br />


            </div>
            <div style="width:45%;float:right;margin-left:10px;margin-top:15px">
                身份证号
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" v-model="IDnumber" style="width:240px">
                <br /><br />
                出生日期
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" v-model="BirthDay" style="width:240px">
                <br /><br />
                性别
                <input type="radio" id="sex1" name="sexname" v-model="sex" value="男">
                <label for="男">男</label>
                <input type="radio" id="sex2" name="sexname" v-model="sex" style="margin-left:20px" value="女">
                <label for="女">女</label>
                <br /><br />
                所属科室<br />
                <select class="btn btn-outline btn-success" style="width:200px" v-model="outid">
                    <option v-bind:value="0">请选择就诊科室</option>
                    <option v-for="itemo in opt" v-bind:value="itemo.outpatient_Id">{{itemo.outpatient_Name}}</option>
                </select>
                <br /><br /><br />
                联系方式
                <input type="search" class="form-control input-sm" aria-controls="DataTables_Table_0" v-model="Iphone" style="width:240px">
                <br /><br />

            </div>
        </div>
        <div class="modal-footer">
            <div>
                <button type="button" class="btn btn-outline btn-default" data-dismiss="modal">退出</button>
                <button type="button" class="btn btn-outline btn-warning"  v-on:click="updatedoctor" >提交</button>
            </div>
        </div>
    </div>



</body>


</html>
<script>

    var did = sessionStorage["did"];

    new Vue({
        el: '#updiv',
        data() {
            return {
                opt: null,
                pfl: null,
                
            }
        },
        mounted() {
            function gpf() {
                return axios
                    .get('/Doctor/GetProfessionals');
            }
            function got() {
                return axios
                    .get('/Doctor/GetOutpatient')
            }
            function getdbat() {
                return axios.get('/Doctor/GetDoctorById', { params: { did: did } });
            }
           
            axios.all([gpf(), got(), getdbat()])

                .then(axios.spread((pfls, opts, getdbats) => {

                    this.pfl = pfls.data;
                    this.opt = opts.data;
                    this.doctor = getdbats.data;

                }))
                .catch(err => {
                    console.log(err);
                })
        },

        methods: {
            updatedoctor: function () {
                var obj = {
                    Doctor_Name: this.Name,
                    Doctor_Age: this.Age,
                    Doctor_Email: this.Email,

                    Outpatient_Id: this.outid,
                    Professional_Id: this.Profid,

                    Doctor_State: 1,         
                    Doctor_Sex: this.sex,
                    Doctor_IDnumber: this.IDnumber,
                    Doctor_Birthday: this.BirthDay,
                    Doctor_Iphone: this.Iphone
                }
                axios
                    .post("/Doctor/UpdateDoctor", window.Qs.stringify(obj))
                    .then(function (response) {
                        if (response.data.success == true) {
                            swal({
                                title: response.data.message,
                                text: "",
                                type: "success",
                                confirmButtonText: "确定",
                                closeOnConfirm: false
                            }, function () {
                                location.reload();
                            })
                        }
                        else {
                            swal({
                                title: response.data.message,
                                text: "",
                                type: "warning",
                                confirmButtonText: "确定",
                                closeOnConfirm: false
                            })
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    })

            }
        }
    })
 
</script>